export default {
  init() {
    return new Promise(function(resolve, reject) {
      if (typeof TMap != 'undefined') {
        resolve(TMap)
        return false
      }
      let script = document.createElement('script')
      script.type = 'text/javascript'
      script.src =
        'https://map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&callback=init'
      script.onerror = reject
      document.head.appendChild(script)
      let interval = setInterval(() => {
        if (typeof TMap != 'undefined') {
          resolve(TMap)
          clearInterval(interval)
        }
      }, 20)
    })
  }
}
